<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>抽奖管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			$("#name").focus();
			 var type = '${lottery.type}';
			 if(type =='') type ="1";
			 $("input[name='type'][value="+type+"]").attr("checked","checked");  
			 
			 var autoClear = '${lottery.autoClear}';
			 if(autoClear =='') autoClear ="0";
			 $("input[name='autoClear'][value="+autoClear+"]").attr("checked","checked");  
			 
			 
			$("#inputForm").validate({
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
		});
		
		function changeScore(){
			
		}
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li><a href="${ctx}/wechat/lottery/activityList">活动奖品列表</a></li>
		<li class="active"><a href="${ctx}/wechat/lottery/activityForm?id=${lottery.id}">奖品<shiro:hasPermission name="wechat:lottery:edit">${not empty lottery.id?'修改':'添加'}</shiro:hasPermission><shiro:lacksPermission name="wechat:lottery:edit">查看</shiro:lacksPermission></a></li>
	</ul><br/>
	<form:form id="inputForm" modelAttribute="lottery" action="${ctx}/wechat/lottery/activitySave" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<form:hidden path="user.id"/>
		<input type="hidden"  value="4"  name="type" />
				
		<tags:message content="${message}"/>
		<div class="control-group">
			<label class="control-label">名称:</label>
			<div class="controls">
				<form:input path="name" htmlEscape="false" maxlength="11" class="required"/>
			</div>
		</div>
		
		<div class="control-group">
			<label class="control-label">自动核销:</label>
			<div class="controls">
				<input type="radio" name="autoClear"  value="1"> 是 &nbsp;&nbsp;&nbsp;<input type="radio" name="autoClear" value="0"> 否  <span class="alert" style="margin-left:150px">中奖及时核销,用于纯添加积分奖品.</span>
			</div>
		</div>
		
		<div class="control-group">
			<label class="control-label">中奖机率:</label>
			<div class="controls">
				<form:input path="percent" htmlEscape="false" maxlength="11" class="required"/>%  <span class="alert">请填写0-100之间的数字,数字越大中奖率就越高.</span>
			</div>
		</div>
		
		<div class="control-group">
			<label class="control-label">增加积分:</label>
			<div class="controls">
				<form:input path="score" id="scoreId" htmlEscape="false" maxlength="11" class="required digits"  />  <span class="alert">请填写0-1000之间的数字,中奖后直接增加该积分.</span>
			</div>
		</div>
		
		<div class="control-group">
			<label class="control-label">奖品数量:</label>
			<div class="controls">
				<form:input path="peramount" htmlEscape="false" maxlength="11" class="required"/>  <span class="alert">针对店家抽奖类型.</span>
			</div>
		</div>
		
		<div class="control-group">
			<label class="control-label">中奖手机号:</label>
			<div class="controls">
				<form:input path="mobile" htmlEscape="false" maxlength="11" />  <span class="alert">针对店家抽奖类型.</span>
			</div>
		</div>
		
		
		<div class="control-group">
			<label class="control-label">备注:</label>
			<div class="controls">
				<form:input path="remarks" htmlEscape="false" maxlength="50" />
			</div>
		</div>
		<div class="form-actions">
			<shiro:hasPermission name="wechat:lottery:edit"><input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;</shiro:hasPermission>
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
		</div>
	</form:form>
</body>
</html>
